﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Autofac;
using Microsoft.AspNetCore.Mvc;

namespace Dapper_Core.Web
{
    public class ControllerModule : Autofac.Module
    {
        protected override void Load(ContainerBuilder builder)
        {
            Type controllerType = typeof(Controller);
            //controllerType.IsAssignableFrom(a)=true说明a是Controller类型，或a是Controller的子类
            builder.RegisterAssemblyTypes(Assembly.Load("Dapper_Core.Web"))
                   .Where(a => controllerType.IsAssignableFrom(a) && a != controllerType).PropertiesAutowired();
        }
    }
}
